<?php
require_once 'choce1/item.php';
class Order{
	private $itemId;
	private $amount;
	private $item = array();
	public function __construct($id=null,$a=null){
		$this->itemId =$id;
		$this->amount =$a;
	}
	public function __get($data){
		return $this->$data;
	}
	public function __set($data,$value){
		$this->$data=$value;
	}
	public function add($ObjectItem){
		$this->item = $ObjectItem;
	}
	public function getObjectItem(){
		$count =1;

		for ($i=0;$i<sizeof($this->item);$i++){
			if($this->itemId==$this->item[$i]->id){
				echo '<tr>';
				echo '<td>'.$count.'</td>';
				echo '<td>'.$this->item[$i]->name.'</td>';
				echo '<td>'.$this->amount.'</td>';
				echo '<td>'.$this->item[$i]->price.'</td>';
				echo '<td>'.$this->calSale($i).'</td>';
				echo '<td>'.$this->calTotal($i).'</td>';
				echo '</tr>';
				$count++;
			}
		}
	}
	function calTotal($i){
		$sum = (($this->item[$i]->price)-$this->calSale($i))*$this->amount;
		return $sum;
	}
	function calSale($i){
		$sum = (($this->item[$i]->price)*($this->item[$i]->sale))/100;
		return $sum;
	}
}

?>